package org.paul.tourism

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity

/**
 *
 *  activity基类，处理统一事件，（比如无网络情况统一提示）
 *
 *  created by paul at 2019-03-26
 *
 */

open class BaseAct : AppCompatActivity(), NetChangeAudience,Logger {
    override fun offLine() {
        d("offLine")
        val viewGroup = window.decorView.findViewById<ViewGroup>(android.R.id.content)
        viewGroup.addView(LayoutInflater.from(this).inflate(R.layout.offline,null,false))
    }

    override fun onLine() {
        d("onLine")
        val viewGroup = window.decorView.findViewById<ViewGroup>(android.R.id.content)
        d(viewGroup.childCount.toString())
    }

    override fun onResume() {
        super.onResume()
        Tourism.instance().subscribeNetChange(this)
    }

    override fun onPause() {
        super.onPause()
        Tourism.instance().unSubscribeNetChange(this)
    }
}